Passed
Pull Request — master (#87)
by Mathieu
01:33
created

FileLocationStrategy.location   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
1
import {ConfigService} from '@nestjs/config';
2
3
export class FileLocationStrategy {
4
  constructor(private readonly configService: ConfigService) {}
5
6
  public async location(fileName: string, uploadedDate: Date): Promise<string> {
7
    const destination = await this.configService.get<string>('UPLOAD_LOCATION');
8
    const month = uploadedDate.getMonth() + 1;
9
    const year = uploadedDate.getFullYear();
10
11
    return `${destination}/${year}/${month}/${fileName}`;
12
  }
13
}
14